//
//  KLMRoomController.swift
//  KLMHome
//
//  Created by Nic on 2025/2/17.
//

import UIKit
import Toast

private let customEmptyViewTag = 1000

class KLMRoomController: KLMRoomListController {

    
    override var rooms: [KLMHomeRoom] {
        didSet {
            if rooms.count > 0 {
                hideEmptyState()
            } else {
                showEmptyState(title: "暂无房间")
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        showEmptyState(title: "暂无房间")
        // Do any additional setup after loading the view.
    }
    
    override func tapEmptyButton(_ button: UIButton) {
        guard let homeId = getNewestHomeId(homeId: self.homeId) else {
            var style = ToastStyle()
            style.titleAlignment = .center
            view.makeToast("请先至 我的 -> 家庭管理 -> 创建家庭", position: .center, title: "提示", style: style)
            return
        }
        let vc = KLMRoomListController(homeId: homeId, operType: .manage)
//            vc.popRefreshBlock = { [weak self] in
//                guard let self = self else { return }
//                self.loadHomeRooms(id: homeId)
//            }
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    override func showEmptyButton() -> Bool {
        true
    }
    
    override func configEmptyButton(_ button: UIButton) {
        button.configStyle(with:"去添加")
    }
}
